package com.yimin.controller;


import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class TestController {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;


    @Resource
    private RedissonClient redissonClient;


    @RequestMapping("/send")
    @ResponseBody
    public void send() {

        // 设置键值对
        redisTemplate.opsForValue().set("Test值", "线程池测试");
        System.err.println("测试Redis信息发送");





    }


    public void doSomething() {
        RLock lock = redissonClient.getLock("lockName");
        try {
            lock.lock();
            // 执行需要加锁的操作
        } finally {
            lock.unlock();
        }
    }



}
